﻿package Classes.Enemies.Aero
{
	import flash.events.Event;	
	import flash.display.Sprite;
	
	import Classes.*;
	import Classes.Elements.*;
	import Classes.Utils.*;
	import Classes.Weapons.Weapon;
	import Classes.Weapons.Rockets.*;
	import Classes.Interface.*;
	
	public class Archer extends Aircraft implements ICarry{	
		public var aCarriee:Array;
				
		public function Archer(){
			speed = 4;
			life = 15;
			hp = 15;
			execution = 20;
			crtspeed = 4;
			accelerate = .5;
			aCarriee = [];
			condition = 100;
			score = UnitType.Archer.score;
		}		

		override protected function move():void{	
			this.hstate = this.x>(this.moverange[1]+this.moverange[0])/2?1:-1;
			carry();
			if(this.y<condition){
				Moving.moveDirectly(this,speed);
			}
			else{
				if(aCarriee[0]){
					aCarriee[0].isdrop = true;
					aCarriee[0].sender = null;
				}
				if(crtspeed<speed)
					crtspeed += accelerate;
				Moving.moveSlanting(this,crtspeed,this.hstate*(this.y-condition)/10,0);
			}			
			hitTest();
		}
		
		public function carry():void{
			if(aCarriee.length>0){
				if(!aCarriee[0].isdrop){
					aCarriee[0].x = this.x;
					aCarriee[0].y = this.y + 10;
				}
			}
		}
		
		public function createCarriee():void{
			var torpedo:Torpedo = new Torpedo();
			torpedo.x = this.x;
			torpedo.y = -15;
			torpedo.aTargets = aTargets;
			torpedo.dimension = dimension;
			torpedo.moverange = moverange;
			torpedo.sender = this;
			dimension.addChildAt(torpedo,0);
			aCarriee.push(torpedo);		
			aFriends.push(torpedo);
		}
	}
}